﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Finbook.GameApp.Models.V4
{
    public class PlayerV4
        : RoleV4
    {
        public PlayerV4(int hp) 
            : base(hp)
        {}

        public override void BeHit(int damage)
        {
            base.BeHit(damage);
            if (HP*1.0f/MaxHP<=0.5f)
            {
                CommonConsole.WriteLine("玩家血量过低，攻击大大增加", ConsoleColor.Magenta);
                foreach (var item in Skills)
                {
                    item.Multiply = 3;
                }
            }
        }

        public override Skill SelectSkill()
        {
            var bSuccess = false;
            int index = 0;
            while (!bSuccess)
            {
                Console.WriteLine($"请选择您的技能{1}~{Skills.Count}");
                var input = Console.ReadLine();
                if (!string.IsNullOrEmpty(input))
                {
                    if (int.TryParse(input, out index))
                    {
                        if (index<=0||index>Skills.Count)
                        {
                            bSuccess = false;
                        }
                        else
                        {
                            bSuccess = true;
                        }
                    }
                    else
                    {
                        bSuccess = false;
                    }
                }
                else
                {
                    bSuccess = false;
                }
            }
            return Skills[index];
        }
    }
}
